﻿namespace CSharpPro._1021;

public class Student
{
    //字段
    private  int id;
    private  string name;
    private string userEmail;
    //属性
    public int Id
    {
        get
        {
            return id;
        }
        set
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(value));
            }
            id = value; 
        }
    }

    public string Name
    {
        get
        {
            return name;
        }
        set => name = value;
        
    }
    
    public Student()
    {
        
    }

    public Student(int id)
    {
        this.id = id;
    }

    

    public Student(int id, String name, String userEmail)
    {
        this.id = id;
        this.name = name;
    }

    public override string ToString()
    {
        //" " + id + " " + name +
        return $"id:{id}, name:{name}, email:{userEmail}";
    }
}